#include "Model.h"

//Model::Model(std::string const &path) {
//    loadModel(path);
//}
//
//Model::~Model() {
//}
//
//void Model::Draw(Shader *shader) {
//    for (unsigned int i = 0; i < meshes.size(); i++) {
//        meshes[i].Draw(shader);
//    }
//}
//
//void Model::loadModel(std::string const &path) {
//    Assimp::Importer importer;
//    const aiScene *scene = importer.ReadFile(path,
//                                             aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_CalcTangentSpace);
//    if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) {
//        std::cout << "error" << std::endl;
//        return;
//    }
//    directory = path.substr(0, path.find_last_of('\\'));
//    processLoad(scene->mRootNode, scene);
//}
//
//void Model::processLoad(aiNode *node, const aiScene *scene) {
//    for (unsigned int i = 0; i < node->mNumMeshes; i++) {
//        aiMesh *curMesh = scene->mMeshes[node->mMeshes[i]];
//        meshes.push_back(processMesh(curMesh, scene));
//    }
//    for (unsigned int i = 0; i < node->mNumChildren; i++) {
//        processLoad(node->mChildren[i], scene);
//    }
//}
//
//Mesh Model::processMesh(aiMesh *mesh, const aiScene *scene) {
//    vector<Vertex> tempVertices;
//    vector<unsigned int> tempIndices;
//    vector<Texture> tempTextures;
//
//    for (unsigned int i = 0; i < mesh->mNumVertices; i++) {
//        Vertex tempVertex;
//        tempVertex.Position.x = mesh->mVertices[i].x;
//        tempVertex.Position.y = mesh->mVertices[i].y;
//        tempVertex.Position.z = mesh->mVertices[i].z;
//
//        tempVertex.Normal.x = mesh->mNormals[i].x;
//        tempVertex.Normal.y = mesh->mNormals[i].y;
//        tempVertex.Normal.z = mesh->mNormals[i].z;
//
//        if (mesh->mTextureCoords[0]) {
//            tempVertex.Texcoord.x = mesh->mTextureCoords[0][i].x;
//            tempVertex.Texcoord.y = mesh->mTextureCoords[0][i].y;
//        } else {
//            tempVertex.Texcoord = glm::vec2(0, 0);
//        }
//        tempVertices.push_back(tempVertex);
//    }
//    for (unsigned int i = 0; i < mesh->mNumFaces; i++) {
//        for (unsigned int j = 0; j < mesh->mFaces[i].mNumIndices; j++) {
//            tempIndices.push_back(mesh->mFaces[i].mIndices[j]);
//        }
//    }
//    return Mesh(tempVertices, tempIndices, {});
//}